package controllers

import (
	//"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

type MysqlController struct {
	beego.Controller
}

const (
	MYSQL_HOST     = "" //数据库host
	MYSQL_PORT     = ""           //数据库端口
	MYSQL_PASSWORD = ""       //连接密码
	MYSQL_NAMW     = ""           //用户名
	MYSQL_DATEBASE = ""           //库名字
)
const (
	DRIVER_NAME   = "mysql"
	DATA_SOURCE   = MYSQL_NAMW + ":" + MYSQL_PASSWORD + "@tcp(" + MYSQL_HOST + ":" + MYSQL_PORT + ")/" + MYSQL_DATEBASE + "?charset=utf8"
	MAX_IDLE_CONN = 10 //最大空闲连接
	MAX_OPEN_CONN = 30 //最大连接
)

func mysqlConnect() {
	orm.Debug = true
	orm.RegisterDataBase("default", DRIVER_NAME, DATA_SOURCE, MAX_IDLE_CONN, MAX_OPEN_CONN)

}
